Skip to content

buffer: pad aligned allocations by a multiple of 8 - #65605

Open
lazerg wants to merge 1 commit into
nodejs:mainfrom
lazerg:fix/issue-65601-pool-alignment
Open

buffer: pad aligned allocations by a multiple of 8#65605
lazerg wants to merge 1 commit into
nodejs:mainfrom
lazerg:fix/issue-65601-pool-alignment

Conversation

@lazerg

@lazerg lazerg commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Reaching an aligned start only needs alignment - 1 extra bytes, but padding by
exactly that much leaves the Buffer.allocUnsafe() pool sitting in a 65599 byte
ArrayBuffer, so a pooled buffer no longer ends on an element boundary of it.
new Uint32Array(buf.buffer, buf.byteOffset) has thrown a RangeError since
v26.8.0 as a result.

Pad by a multiple of 8 instead. Backing store addresses are 8 byte aligned too,
so what is left after the buffer stays a whole number of elements, as it was
before v26.8.0.

The accepted size drops by one byte for alignments above 8, since that much
more is now allocated.

Fixes: #65601

@nodejs-github-bot nodejs-github-bot added buffer Issues and PRs related to the buffer subsystem. needs-ci PRs that need a full CI run. labels Aug 27, 2026
Signed-off-by: Lazizbek Ergashev <lazerg2@gmail.com>
@lazerg lazerg changed the title buffer: pad aligned allocations to a whole alignment buffer: pad aligned allocations by a multiple of 8 Aug 27, 2026
@lazerg
lazerg force-pushed the fix/issue-65601-pool-alignment branch from f92df5e to 89195be Compare August 27, 2026 22:09
@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.05%. Comparing base (1c8799d) to head (89195be).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65605      +/-   ##
==========================================
- Coverage   90.06%   90.05%   -0.01%     
==========================================
  Files         751      751              
  Lines      254916   254927      +11     
  Branches    48122    48128       +6     
==========================================
- Hits       229588   229581       -7     
- Misses      16502    16518      +16     
- Partials     8826     8828       +2     
Files with missing lines Coverage Δ
lib/buffer.js 99.15% <100.00%> (+<0.01%) ⬆️
lib/internal/buffer.js 98.87% <100.00%> (+<0.01%) ⬆️
src/node_buffer.cc 69.23% <ø> (-0.18%) ⬇️

... and 29 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

buffer Issues and PRs related to the buffer subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression in Node.js 26.8.0: aligned Buffer pool breaks multi-byte typed-array views

2 participants